function sreload(){
	location.reload()
}
function mapreload(){
	xmlhttp=new XMLHttpRequest()
	xmlhttp.open("GET","socket.php?action=rmap",true)
	xmlhttp.send()
	location.reload()
}

var xmlhttp
if(window.XMLHttpRequest)
	{
	xmlhttp=new XMLHttpRequest()
	}else{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
		xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			console.log(xmlhttp.responseText)
			document.getElementById("hid").innerHTML=xmlhttp.response
			}
		}
xmlhttp.open("GET","bow.txt",false)
xmlhttp.send()
var Bow = new Array()
var hid = document.getElementById('hid')
map = hid.innerHTML
Bow = map.toString().split(",")
var ls=0
for(i=0;i<=99;i++){
	if(Bow[i]=='-1'){
		ls=ls+1
	}
}
var lei = document.getElementById("lei")
lei.innerHTML="去战斗吧，请小心！雷总数："+ Number(ls)
for(i = 1 ; i<=10;i++){
	var tr = document.getElementById(i);
	for(var ii = 1;ii<=10;ii++){
		var td = document.createElement("td")
		var btn = document.createElement("button");
		var a = (Number(i-1)*10+Number(ii))-1
		if (Bow[a] >=0) {
			btn.setAttribute("onclick", "Click("+(Number(i-1)*10+Number(ii))+");");
			btn.setAttribute("id",i*10+ii)
			btn.setAttribute("class","btn")
			btn.innerHTML = Bow[a]
			td.appendChild(btn)
			tr.appendChild(td)
		} else if(Bow[a] ==-3){
			btn.setAttribute("onclick", "Click("+(Number(i-1)*10+Number(ii))+");");
			btn.setAttribute("id",i*10+ii)
			btn.setAttribute("class","lei")
			btn.innerHTML = "雷"
			td.appendChild(btn)
			tr.appendChild(td)
		}else{
			btn.setAttribute("onclick", "Click("+(Number(i-1)*10+Number(ii))+");");
			btn.setAttribute("id",i*10+ii)
			btn.setAttribute("class","btn")
			btn.innerHTML = ""
			td.appendChild(btn)
			tr.appendChild(td)
		}
	}
}
function Click(id){
	if(window.XMLHttpRequest)
		{
		xmlhttp=new XMLHttpRequest()
		}else{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
			}
			xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4 && xmlhttp.status==200){
				console.log(xmlhttp.responseText)
				location.reload()
				}
			}
	xmlhttp.open("GET","socket.php?action=send&text="+id,false)
	xmlhttp.send()
}